#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

const int N = 1e5 + 10;
int a[N], cnt[N];
int n, m;
int check(int x)
{
    int ret = 0;
    for (int i = 1; i <= n; i++)
    {
        ret += cnt[i] / x + (cnt[i] % x == 0 ? 0 : 1);
    }
    return ret;
}
int main()
{
    int count = 0, maxCnt = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        if (cnt[a[i]] == 0) count++;
        cnt[a[i]]++;
        maxCnt = max(maxCnt, cnt[a[i]]);
    }
    int falg = 1 , l =1 ,r = maxCnt;
    if (count > m)
    {
        cout << -1 << endl;
        return 0;
    }
   /* for (int i = 1; i <= maxCnt; i++)
    {
        if (check(i) <= m)
        {
            cout << i << endl;
            falg = 0;
            break;
        }
    }*/
    while (l < r) 
    {
        int mid = (l + r)/2;
        if (check(mid) <= m)      r = mid;
        else l = mid + 1;
        
    }
    
    cout << l << endl;

    return 0;
}